package com.zb.framework.api.fallback;

import com.zb.framework.api.dto.DemoDTO;
import com.zb.framework.api.microservice.DemoMicroService;
import com.zb.zeus.common.core.web.domain.AjaxResult;
import lombok.extern.slf4j.Slf4j;
import org.springframework.cloud.openfeign.FallbackFactory;
import org.springframework.stereotype.Service;

/**
 * @author fujianjian
 * @date 2021/9/8 10:07
 **/
@Slf4j
@Service
public class DemoMicroServiceFallbackFactory implements FallbackFactory<DemoMicroService> {
    @Override
    public DemoMicroService create(Throwable cause) {
        log.info("调用xxx系统样例微服务失败, 现生成降级服务", cause);
        return new DemoMicroService() {
            @Override
            public AjaxResult detail(DemoDTO reqDto) {
                return AjaxResult.error("获取详情信息失败");
            }

            @Override
            public AjaxResult greet(String source) {
                return AjaxResult.error("open feign 调用失败");
            }
        };
    }
}
